import {Component} from 'react'
import {View} from "@tarojs/components";
import {Image} from "@antmjs/vantui";
import './GoodsItem.less'
import TakeDownPng from './images/takedown.png';

export interface GoodsItemProps {
  takedown: boolean,
  image: string,
  title: string,
  desc: string,
  price: string
}

export default class GoodsItem extends Component<GoodsItemProps> {

  constructor(props) {
    super(props);
  }

  render() {
    let priceArray = this.props.price.split('.');

    return <View className='goods-item-container'>
      <View className='goods-item-image-container'>
        <Image className='goods-item-image' src={this.props.image}></Image>
        {this.props.takedown && <View className='goods-item-take-down'>
          <Image src={TakeDownPng} />
        </View>}
      </View>
      <View className='goods-item-title'>
        {this.props.title}
      </View>
      <View className='goods-item-desc'>
        {this.props.desc}
      </View>
      <View className='goods-item-price'>
        <View className='price-tag'>￥</View>
        <View className='price-integer'>{priceArray[0]}</View>
        <View className='price-double'>.{priceArray[1]}</View>
      </View>

    </View>;
  }

}
